package com.example.shaoying.yuejian.fragment.clubeFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.shaoying.yuejian.R;
import com.example.shaoying.yuejian.adapter.ClubListAdapter;
import com.example.shaoying.yuejian.javabean.ClubList;
import com.example.shaoying.yuejian.model.ClubeModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


public class Clube01Fragment extends Fragment {

    private View view;
    private RecyclerView recyclerView;
    private List<ClubList> clubLists;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view=inflater.inflate(R.layout.clube01, container, false);
        recyclerView= (RecyclerView) view.findViewById(R.id.club_list1);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        getData();
        return view;
    }
    private void getData() {

        ClubeModel clubeModel=new ClubeModel();
        Call<List<ClubList>> call=clubeModel.getClubeList();
        call.enqueue(new Callback<List<ClubList>>() {
            @Override
            public void onResponse(Call<List<ClubList>> call, Response<List<ClubList>> response) {
                clubLists= response.body();
                recyclerView.setAdapter(new ClubListAdapter(getActivity(), clubLists));
            }

            @Override
            public void onFailure(Call<List<ClubList>> call, Throwable t) {

            }
        });
    }

}
